// -------------------
const fs = require("fs");
const buffer = Buffer.from("hello world");
const path = require("path");
fs.open(path.join(__dirname, "1.text"), "r+", (err, fd) => {
  if (err) {
    return console.log(err);
  }
  fs.appendFileSync(path.join(__dirname, "1.text"), buffer);
  fs.read(fd, buffer, 0, buffer.length, null, (err, bytesRead, buf) => {
    if (err) {
      return console.log(err);
    }
    console.log(bytesRead, buf.toString("utf-8"));
  });
});
